//package com.itstyle.cloud.common.config;
//
//import com.alibaba.fastjson.support.spring.FastJsonRedisSerializer;
//import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.serializer.StringRedisSerializer;
//
///**
// * redis配置<br>
// * 集群下启动session共享，需打开@EnableRedisHttpSession<br>
// * 单机下不需要
// *
// * @author auth
// * <p>
// * 2017年8月10日
// */
//@Configuration
//public class RedisConfig {
//
////    @SuppressWarnings({"unchecked", "rawtypes"})
////    @Bean("redisTemplate")
////    public RedisTemplate redisTemplate(@Lazy RedisConnectionFactory connectionFactory) {
////        RedisTemplate redis = new RedisTemplate();
////        GenericToStringSerializer<String> keySerializer = new GenericToStringSerializer<String>(String.class);
////        redis.setKeySerializer(keySerializer);
////        redis.setHashKeySerializer(keySerializer);
////        GenericJackson2JsonRedisSerializer valueSerializer = new GenericJackson2JsonRedisSerializer();
////        redis.setValueSerializer(valueSerializer);
////        redis.setHashValueSerializer(valueSerializer);
////        redis.setConnectionFactory(connectionFactory);
////
////        return redis;
////    }
//
//
//    @Bean
//    @ConditionalOnMissingBean(name = "redisTemplate")
//    public RedisTemplate<Object, Object> redisTemplate(
//            RedisConnectionFactory redisConnectionFactory) {
//        RedisTemplate<Object, Object> template = new RedisTemplate<>();
//        //使用fastjson序列化
//        FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(Object.class);
//
//        // key的序列化采用StringRedisSerializer
//        template.setKeySerializer(new StringRedisSerializer());
//        // value值的序列化采用fastJsonRedisSerializer
//        template.setValueSerializer(fastJsonRedisSerializer);
//
//
//        template.setHashValueSerializer(fastJsonRedisSerializer);
//        template.setHashKeySerializer(new StringRedisSerializer());
//
//        template.setConnectionFactory(redisConnectionFactory);
//        return template;
//    }
//
//
//}
